<template>
   <div>
      <div class="info_con clearfix">
         <h3 class="common_title2">基本信息</h3>
         <ul class="user_info_list">
            <li><span>用户名：</span>{{ user.username }}</li>
            <li><span>手机号：</span>{{ user.phone }}</li>
            <li>
               <span>Email：</span>
               <div v-if="set_email">
                  <input v-model="user.email" type="email" name="email">
                  <input @click="save_email" type="button" name="" value="保 存">
                  <input @click="set_email=false" type="reset" name="" value="取 消">
                  <div v-if="email_error">邮箱格式错误</div>
               </div>
               <div v-else-if="user.email">
                  {{ email }}
                  <div v-if="email_active">已验证</div>
                  <div v-else>
                     待验证<input @click="save_email" :disabled="send_email_btn_disabled" type="button"
                               :value="send_email_tip">
                  </div>
               </div>
               <div v-else>
                  <input @click="set_email=true" type="button" name="" value="设 置">
               </div>
            </li>
         </ul>
      </div>

      <h3 class="common_title2">最近浏览</h3>
<!--      更换下列代码, 加载后台获取的数据-->
      <div class="has_view_list">
         <ul class="goods_type_list clearfix">
            <li v-for="sku in histories">
               <a :href="sku.url"><img :src="sku.default_image_url"></a>
               <h4><a :href="sku.url">{{sku.name}}</a></h4>
               <div class="operate">
                  <span class="prize">￥{{sku.price}}</span>
                  <span class="unit">{{sku.comments}}评价</span>
               </div>
            </li>
         </ul>
      </div>
   </div>
</template>

<script>
   import BaseHeader2 from "../Header/BaseHeader2";

   export default {
      name: "UserInfo",
      components: {
         BaseHeader2,
      },
      data() {
         return {
            user: {},
            username: '',
            phone: '',
            email: '',


            set_email: '',
            email_error: '',
            email_active: '',
            send_email_btn_disabled: '',
            send_email_tip: '',

            histories: []
         }
      },
      methods: {
         save_email(){},

      },
      created() {
         this.$axios({
            url: 'userapp/personal/',
            method: 'GET',
            params: {
               token: sessionStorage.getItem('token')
            }
         }).then(resp=>{
            this.user = resp.data
         })
      },
      computed: {},
      filters: {},
      watch: {},
   }
</script>

<style scoped>

</style>
